package cn.schoolwow.quickdao.module.database.dql.response.service;

import cn.schoolwow.quickdao.module.database.dql.response.flow.GetArrayFlow;
import cn.schoolwow.quickdao.module.database.dql.response.flow.GetListFlow;
import cn.schoolwow.quickdao.module.database.dql.response.flow.common.ExecuteConditionStatementFlow;
import cn.schoolwow.quickdao.module.database.dql.response.flow.common.SetConditionParameterFlow;
import cn.schoolwow.quickdao.module.database.dql.response.flow.common.SetConditionStatementFlow;
import cn.schoolwow.quickflow.QuickFlowExecutor;
import cn.schoolwow.quickflow.flow.CompositeBusinessFlow;

public class GetPagingListCompositeBusiness implements CompositeBusinessFlow {
    @Override
    public void executeCompositeBusiness(QuickFlowExecutor quickFlowExecutor) {
        Object clazz = quickFlowExecutor.getFlowContext().getData("clazz");
        quickFlowExecutor.next(new GetCountFlow())
                .next(new SetConditionStatementFlow())
                .next(new SetConditionParameterFlow())
                .next(new ExecuteConditionStatementFlow())
                .next(null==clazz?new GetArrayFlow():new GetListFlow());
    }

    @Override
    public String name() {
        return "分页获取数据库列表";
    }
}
